import {
  TokenRequestData,
  TableResponseData,
  OptionsType,
  feeRulesType,
  tradeExtensionDataType
} from '@/types/interface'
import {
  UserAccountType,
  GenderType,
  BizType,
  DepositType,
  PaymentType,
  BikeTermOrderStatusCodeType,
  VoltageType,
  BatteryTermOrderStatusCodeType,
  orderChangedType,
  userCouponType,
  BikeModifieldsOrderStatusCodeType,
  CouponType
} from '@/types/enum'
import { StoreTableCol } from '@/api/store/types/store'

/**
 * 获取用户列表
 * @param status  0 - 冻结
 * @param status  1 - 正常
 * @param status  2 - 注销
 */
export interface queryUserInfoRequestData extends TokenRequestData {
  name: string
  phone: string
  storeId: string
  status: UserAccountType | ''
  idCard?: string
}

export interface queryUserInfoTableCol {
  userId: number //用户id
  userName: string //用户名
  nickName: string
  mobilePhone: string
  gender: GenderType
  address: string
  cityId: number //所在城市id
  status: UserAccountType
  createdTime: string
  idCard: string //身份证号
  lastLoginTime: string | null
  storeName: string
  balance: string
}
export type queryUserInfoResponseData = TableResponseData<queryUserInfoTableCol>

export type queryUserInfoResponse = ApiResponseData<queryUserInfoResponseData>

/**
 * 解冻用户
 */
export interface userFrozenUnfreezeRequestData extends TokenRequestData {
  phone: string
  status: '1'
}

export type userFrozenUnfreezeResponse = ApiResponseData<string>

/**
 * 获取用户详情数据
 */

export interface queryUserInfoDetailRequestData extends TokenRequestData {
  userId: string
}
export type queryUserInfoDetailResponse = ApiResponseData<OptionsType[]>

/**
 * 获取用户详情订单
 */

export interface queryUserInfoDetailOrderRequestData extends TokenRequestData {
  phone: string
  orderId: string
  type: string
  selectType: string
}
/**
 * 用户详情-充值订单 返回列数据
 */
export interface ChargeDetailOrderTableCol {
  orderId: string
  userId: string
  bizType: BizType
  orderAmount: number
  paymentGateWay: string
  paymentType: PaymentType
  depositType: DepositType
  discountAmount: string
  tradeTime: string
  originOrderId: string
  remark: string
  createdTime: string
  remainRefundAmount: number
  balance: number
}
/**
 * 用户详情-车辆套餐 返回列数据
 */
export interface BikePackageDetailOrderTableCol {
  orderId: string
  userId: string
  userName: string
  mobilePhone: string
  name: string
  bizType: BizType
  orderAmount: string
  productModel: string
  deposit: string
  overdueAmount: string
  startTime: string
  rentTime: string
  remainingTime: string
  orderStatusCode: BikeTermOrderStatusCodeType
  payStatus: '已支付' | '待支付'
  orderChanged: orderChangedType
  orderDetailStatusDescription: string
  rentEquity: string[]
  createdTime: string
}
/**
 * 用户详情-电池套餐 返回列数据
 */
export interface BatteryPackageDetailOrderTableCol {
  orderId: string
  userId: string
  userName: string
  mobilePhone: string
  name: string
  bizType: BizType
  inputVoltage: VoltageType
  orderAmount: string
  productModel: string
  rent: string
  deposit: string
  overdueAmount: string
  startTime: string
  rentTime: string
  remainingTime: string
  orderChanged: orderChangedType
  orderStatusCode: BatteryTermOrderStatusCodeType
  orderDetailStatusDescription: string
  payStatus: '已支付' | '待支付'
  createdTime: string
}

/**
 * 用户详情-短租消费 返回列数据
 * @param tradeExtensionData 骑行总费用详情
 * @param rideAmount - 骑行总费用
 * @param orderAmount  - 其他总费用
 * @param otherExTensionData - 其他总费用详情
 * @param rentcardName - 骑行卡名称
 */
export interface bikeShortTermDetailOrderTableCol {
  orderId: string
  phone: string
  bikeId: string
  bikeCode: string
  startTime: string
  endTime: string
  rideDistance: string
  rideDuration: string
  rideAmount: string
  orderAmount: string
  userId: string
  storeId: string
  feeRules: feeRulesType[]
  /**
   * 付费状态
   * @param 2 已支付
   * @param 1 未支付
   */
  status: '2' | '1'
  /** 付费状态映射 若为未支付 携带金额文本 */
  statusName: string
  tradeExtensionData: tradeExtensionDataType
  otherExTensionData: tradeExtensionDataType
}
/**
 * 用户详情-退款记录 返回列数据
 */
export interface refundRecordDetailOrderTableCol {
  phone: string
  orderId: string
  refundType: string
  refundAmount: string
  refundOrderId: string
  refundTime: string
  reason: string
  accountType: PaymentType
}
/**
 * @description 用户详情-中控线材电池 返回列数据
 * @param payTime - 下单时间
 * @param changedTime - 已完成/已取消时间
 * @param lockId - 编号
 */
export interface bikeModifieldsDetailOrderTableCol {
  orderId: string
  userId: string
  userName: string
  mobilePhone: string
  shortName: string
  orderAmount: number
  storeInfo: StoreTableCol
  lockId: string
  payment: string
  changedTime: string
  payTime: string
  orderStatusCode: BikeModifieldsOrderStatusCodeType
  orderDetailStatusDescription: string
}
/** 用户详情-单次换电订单 返回列数据 */
export interface batterySwapDetailOrderTableCol {
  orderId: string //订单号
  userId: string //用户Id
  userName: string //用户名
  mobilePhone: string
  orderAmount: number
  storeInfo: null | StoreTableCol //门店信息
  boxCode: string //电柜编号
  payment: PaymentType //支付方式
  changeStatus: string //订单状态
  payTime: string //支付时间
  changeTime: string //换电时间
  putInDoor: string //还电仓门
  takeOutDoor: string //取电仓门
}
/**
 * 用户详情-用户卡券 返回列数据
 */
export interface userCouponDetailOrderTableCol {
  userPhone: string
  couponName: string
  couponType: string
  count: string
  expiryDate: string
  usageScope: string
  usageCondition: string
  status: userCouponType
  usageDate: string
}

/** 用户详情- 违规收费 */
export interface IllegalChargesDetailOrderTableCol {
  phone: string
  orderId: string
  userId: string
  bizType: BizType
  bikeCode: string
  amount: number
  reason: string
  operator: string
  imageUrls: string
  extensionData: string
  tradeNo: string
  paymentType: PaymentType
}

export type queryUserInfoDetailOrderTableCol =
  | userCouponDetailOrderTableCol
  | refundRecordDetailOrderTableCol
  | bikeShortTermDetailOrderTableCol
  | BatteryPackageDetailOrderTableCol
  | ChargeDetailOrderTableCol
  | BikePackageDetailOrderTableCol
  | bikeModifieldsDetailOrderTableCol
  | batterySwapDetailOrderTableCol
  | IllegalChargesDetailOrderTableCol

export type queryUserInfoDetailOrderResponseData =
  TableResponseData<queryUserInfoDetailOrderTableCol>

export type queryUserInfoDetailOrderResponse = ApiResponseData<queryUserInfoDetailOrderResponseData>

/** 清除实名信息 */
export interface cancelIdCardVerifyRequestData extends TokenRequestData {
  userId: number
}
export type cancelIdCardVerifyResponse = ApiResponseData<string>

/** 赠送卡券 */
export interface sendCouponRequestData extends TokenRequestData {
  userId: number | string
  couponType: CouponType
  discountAmount: string
  minOrderAmount: string
  startDate: string
  endDate: string
  count: number
  coupon: string
}
export type sendCouponResponse = ApiResponseData<string>
